def solution(nums):
    nums = list(str(nums))
    result = []
    for i in range(len(nums)):
        cur_max = nums.pop(nums.index(max(nums)))
        result.append(cur_max)
    return ''.join(result)


if __name__ == '__main__':
    print(solution(123456))
